package com.ruoyi.web.controller.business;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.WcContentExamine;
import com.ruoyi.system.domain.WcContentExamineAncillary;
import com.ruoyi.system.domain.vo.business.*;
import com.ruoyi.system.service.IWcContentExamineAncillaryService;
import com.ruoyi.system.service.IWcContentExamineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 影片内容审查Controller
 *
 * @author ruoyi
 * @date 2024-02-28
 */
@Controller
@Api(tags = {"影片内容审查"})
@RequestMapping("/system/wcContentExamine")
public class WcContentExamineController extends BaseController {

    @Autowired
    private IWcContentExamineService wcContentExamineService;

    @Autowired
    private IWcContentExamineAncillaryService ancillaryService;

    /**
     * 查询影片内容审查列表
     */
    @ApiOperation("查询影片内容审查审核列表")
//    @PreAuthorize("system:application:list")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:list')")
    @PostMapping("/list")
    @ResponseBody
    public AjaxResult<Page<WcContentExamineSelectListVO>> list(@RequestBody WcContentExamineSelectListDto dto)  {
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.getList(dto);
        return success(list);
//        return getDataTable(list);
    }

    // todo 影片审查开始
    /**
     * 查询影片内容审查--受理列表
     */
    @ApiOperation("影片内容审查--查询影片内容审查【受理】列表")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:list')")
    @PostMapping("/acceptanceList")
    @ResponseBody
    public AjaxResult<Page<WcContentExamineSelectListVO>> acceptanceList(@RequestBody WcContentExamineSelectListDto dto)  {
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.acceptanceList(dto);
        return success(list);
    }

    /**
     * 查询影片内容审查--【专家评审】列表
     */
    @ApiOperation("影片内容审查--查询影片内容审查【专家评审】列表")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:list')")
    @PostMapping("/expertReviewList")
    @ResponseBody
    public AjaxResult<Page<WcContentExamineSelectListVO>> expertReviewList(@RequestBody WcContentExamineSelectListDto dto)  {
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.expertReviewList(dto);
        return success(list);
    }

    /**
     * 查询影片内容审查--【公示发证】列表
     */
    @ApiOperation("影片内容审查--查询影片内容审查【公示发证】列表")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:list')")
    @PostMapping("/publicizeCertificationList")
    @ResponseBody
    public AjaxResult<Page<WcContentExamineSelectListVO>> publicizeCertificationList(@RequestBody WcContentExamineSelectListDto dto)  {
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.publicizeCertificationList(dto);
        return success(list);
    }

    /**
     * 查询影片内容审查--【审查决定】列表
     */
    @ApiOperation("影片内容审查--查询影片内容审查【审查决定】列表")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:list')")
    @PostMapping("/reviewDecisionList")
    @ResponseBody
    public AjaxResult<Page<WcContentExamineSelectListVO>> reviewDecisionList(@RequestBody WcContentExamineSelectListDto dto)  {
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.reviewDecisionList(dto);
        return success(list);
    }

    /**
     * 查询影片内容审查--【公示信息】列表
     */
    @ApiOperation("影片内容审查--查询影片内容审查【公示信息】列表")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:list')")
    @PostMapping("/publicityInfoList")
    @ResponseBody
    public AjaxResult<Page<WcContentExaminePublicityInfoListVO>> publicityInfoList(@RequestBody WcContentExaminePublicityInfoListDto dto)  {
        Page<WcContentExaminePublicityInfoListVO> list = wcContentExamineService.publicityInfoList(dto);
        return success(list);
    }

    // todo 影片审查结束

    /**
     * 导出影片内容审查列表
     */
    @ApiOperation("导出影片内容审查列表")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:export')")
    @Log(title = "影片内容审查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(@RequestBody WcContentExamineSelectListDto dto) {
        Page<WcContentExamineSelectListVO> list = wcContentExamineService.getList(dto);
        ExcelUtil<WcContentExamineSelectListVO> util = new ExcelUtil<>(WcContentExamineSelectListVO.class);
        return util.exportExcel(list.getRecords(), "影片内容审查数据");
    }


    /**
     * 影片内容审查详情
     */
    @ApiOperation("影片内容审查详情")
    //@RequiresPermissions("system:application:edit")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:detail')")
    @GetMapping("/edit/{id}")
    @ResponseBody
    public AjaxResult edit(@PathVariable("id") Long id) {
        WcContentExamineDetailVO vo = wcContentExamineService.selectWcContentExamineDetailVOById(id);
        return success(vo);
    }

    /**
     * 修改保存影片内容审查
     */
    @ApiOperation("修改影片内容审查")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:edit')")
    @Log(title = "影片内容审查", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@RequestBody WcContentExamine wcContentExamine) {
        return toAjax(wcContentExamineService.updateWcContentExamine(wcContentExamine));
    }

    /**
     * 删除影片内容审查
     */
    @ApiOperation("删除影片内容审查")
    //@RequiresPermissions("system:application:remove")
    @PreAuthorize("@ss.hasPermi('system:contentExamine:remove')")
    @Log(title = "影片内容审查", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(Long id) {
        //删除附件
        ancillaryService.remove(Wrappers.lambdaQuery(WcContentExamineAncillary.class).
                eq(WcContentExamineAncillary::getWcContentExamineId,id));
        return toAjax(wcContentExamineService.removeById(id));
    }
}
